package com.sharemarking.platform.controller;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sharemarking.system.dto.ExceptionType;
import com.sharemarking.system.exception.ApiException;

@ControllerAdvice(basePackageClasses=IndexController.class)
public class IndexControllerAdvice {

	@ExceptionHandler(value=ApiException.class)
	@ResponseBody
	public ResponseEntity<ExceptionType> defaultErrorHandler(ApiException e) {
		return new ResponseEntity<ExceptionType>(e.getExceptionType(),HttpStatus.BAD_REQUEST);
    }
	
}
